<template>
  <ul class="contentLeft">
    <li
      v-for="(item,index) in leftNavArr"
      :key="index"
      @click="clickLeftNav(index)"
      :class="{selected : index == currentIndex}"
    >{{item.title}}</li>
  </ul>
</template>

<script>
export default {
  name: "CateLeftnav",
  props: {
    leftNavArr: Array,
    default() {
      return [];
    }
  },
  computed: {},
  data() {
    return {
      currentIndex: 0
    };
  },
  methods: {
    clickLeftNav(index) {
      this.currentIndex = index
      this.$emit('handleLeftNav',index)
    }
  }
};
</script>

<style scoped>
/* 内容左侧 */

.contentLeft {
  width: 100px;
  height: 100%;
  overflow: scroll;
  background-color: #f6f6f6;
}
.contentLeft li {
  height: 45px;
  line-height: 45px;
  font-size: 14px;
  text-align: center;
  color: #666;
  border-bottom: 1px solid #ccc;
}
/* li被选中的样式 */
li.selected {
  border-left: 2px solid red;
  color: var(--color-high-text);
  background-color: #fff;
}
</style>
